/*
# sample: 3个重复站点
# 2018-9-22: 用StaticBase、DynBase代替了BaseDir ，但仍旧兼容BaseDir参数
Control = "/test"
CtlUrl = "http://127.0.0.1"
FcgiAddr ="127.0.0.1:9990"

[sites."site1"]
Addr = "127.0.0.1:5432"
Database = "db1"
User = "userx"
Password = "password"
FcgiBase = "/d1"
StaticRoot = "/s1"
#BaseDir = "home/sites/site1"
#设置BaseDir时，下面两个参数无效
StaticBase = "/home/sites/www/s1"
DynBase = "/home/sites/site1"

[sites."site2"]
addr = "127.0.0.1:5432"
database = "db2"
user = "userx"
pwd = "password"
FcgiBase = "/d2"
StaticRoot = "/s2"
StaticBase = "/home/sites/www/s2"
DynBase = "/home/sites/site2"

[sites."site3"]
addr = "127.0.0.1:5432"
database = "db3"
user = "userx"
pwd = "password"
FcgiBase = "/d3"
StaticRoot = "/s3"
StaticBase = "/home/sites/www/s3"
DynBase = "/home/sites/site3"
*/
package main

import (
	"log"

	"github.com/BurntSushi/toml"
)

type config struct {
	Control  string                       `toml:"Control"`
	CtlUrl   string                       `toml:"CtlUrl"`
	FcgiAddr string                       `toml:"FcgiAddr"`
	Sites    map[string]map[string]string `toml:"Sites"`
}

func readToml(filename string) *config {
	var conf1 = new(config)
	_, err := toml.DecodeFile(filename, conf1)
	if err == nil {
		return conf1
	} else {
		log.Printf("readToml: %v\n", err)
		return nil
	}
}
